﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Linq.Expressions;
using System.Diagnostics;

namespace APIExplorer
{
    public static class NotifyPropertyChangedExtension
    {
        public static void FireEvent<T, TResult>(this T target, PropertyChangedEventHandler handler , Expression<Func<T, TResult>> expression  )
            where T : INotifyPropertyChanged
        {
            MemberExpression memberExpression = expression.Body as MemberExpression;
            Debug.Assert(memberExpression != null);
            if (handler != null)
                handler(target, new PropertyChangedEventArgs(memberExpression.Member.Name));
        }
    }
}
